<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="./vue.js"></script>
</head>

<body>
  <div id="app">
    {{name}}
    父组件
    <cpn></cpn>
    <cpn ref="aaa"></cpn>
    <cpn></cpn>
    <button @click="btnClick">按钮</button>
  </div>
  <template id="cpn">
    <div>
      <h2>子组件</h2>
    </div>
  </template>
  <script>
    var vm = new Vue({
      el: '#app',
      data: {
        name: 'Taec'
      },
      methods: {
        btnClick() {
          // this.$children[0].showMessage();
          // console.log(this.$children[0].name);
          console.log(this.$refs.aaa);

        }
      },
      components: {
        cpn: {
          template: "#cpn",
          methods: {
            showMessage() {
              console.log('aaaa');
            }
          },
          data() {
            return {
              name: '子组件'
            }
          }
        }
      }
    })
  </script>
</body>

</html>